<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <button style="color: red;">1</button>
    <button>2</button>
    <button>3</button>

    <script>

        // 清除掉所有的，再给当前这一个添加颜色

        var oBtns = document.querySelectorAll('button');

        for (var i = 0; i < oBtns.length; i++) {
            oBtns[i].onclick = function () {
                // 全部清除掉
                for (var j = 0; j < oBtns.length; j++) {
                    oBtns[j].style.color = 'black';
                }

                // 然后给当前这一个加颜色
                this.style.color = 'red';
            }
        }

    </script>

</body>

</html>